import { useHttp } from "utils/http";
import { cleanObject } from "utils/index";
import { User } from "type/user";
import { useQuery } from "react-query";

export const useUsers = (param?: Partial<User>) => {
  const client = useHttp();
  return useQuery<User[]>(
    ['users', param],
    () => client('users', { data: cleanObject(param || {}) })
  )
  // const { run, ...result } = useAsync<User[]>();

  // useEffect(() => {
  //   run(client("users", { data: cleanObject(param || {}) }));
  // }, [param, client, run]);

  // return result;
};
